// SCENARIO SCRIPT

// This is the special script for your entire scenario. It contains
// special encounters and code accessable from anywhere in the scenario. it also
// contains the code that initializes important special things in the
// scenario (like shops and names and descriptions of special items).

// You can create your own states, but you should give all of them numbers greater than
// or equal to 10.

beginscenarioscript;

variables;
short choice,i,j,k;
short level,tick;

body;

// This is the state that is called every time the scenario is loaded,
// even when a save file in the scenario is loaded. Some things that should go here:
//    Names and descriptions of special items.
//    Names and effects of custom special abilities.
beginstate LOAD_SCEN_STATE;
	//turn_on_debug_mode();
	init_special_item(0,"Star Emblem","A seven pointed star that is the emblem of the Order of Virtues.");
	init_special_item(1,"Package","This package is from the wizard's guild of Cyprus to some customer in Cigosal. It's already late.");
	init_special_item(3,"Key","This is the key that the priest used to lock the door to the infirmary.");
	i = get_flag(255,1);
	break;

// This is the state that is called only once at the very beginning of 
// the scenario. Some things that should go here:
//    The stuff in shops.
//    Creating horses and boats.
beginstate START_SCEN_STATE;
i = -1;
k = 0;
while(k <= 3){
	if((char_ok(k) == 1) && (get_species(k) == 0) && (get_level(k) < 100)){
		if(i == -1)
			i = k;
	}
	k = k + 1;
}
set_flag(255,1,i);
set_flag(240,0,50);
create_horse(0,26,43,46,0);
break;

// This state is called every tick wherever the party is in the scenario.
// You can use the set_state
beginstate START_STATE;
set_ticks_forward(-1);
if(get_crime_level() > 0){
	message_dialog("That's not how I remember it....","");
	end_scenario(0);
}
if(char_ok(i) == 0){
	k = 0;
	j = -1;
	while(k <= 3){
		if(char_ok(k) == 1)
			j = k;
		k = k + 1;
	}
	if(k > -1){
		//print_num(num_chars_in_group(0));
		message_dialog("You were warned not to switch party formation. Sorry but I can't let you stay.","");
		kill_char(first_group_member(0),3,0);	
	}
}
if((get_flag(18,1) == 0) && (get_flag(14,1) == 1))
	set_char_status(i,13,15 - get_char_status(i,13),1,0);
	
break;

// Place your own states below. Give each a number at least 10.
beginstate 10;
break;
